<template>
	<view>
		<view class="main">
			<u-subsection :list="list" :current="current" @change="change" active-color="#ff9900"></u-subsection>
			<view class="order-list">
				<view class="order-item" v-for="item in orderList">
					<view class="top">
						<text>{{item.path}}</text>
						<view class="status" v-if="item.status === 0">未付款</view>
						<view class="status" v-else style="background-color: #909399;">已付款</view>
					</view>
					<view class="id">{{item.orderNum}}</view>
					<view class="date">{{item.createTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						name: '未付款'
					},
					{
						name: '已付款'
					}
				],
				current: 0,
				orderList: []
			};
		},
		onLoad() {
			this.getOrder()
		},
		methods:{
			change(index){
				this.current = index
				this.getOrder()
			},
			getOrder(){
				this.$request({
					url: '/prod-api/api/bus/order/list'
				}).then(res => {
					console.log(res)
					this.orderList = res.rows.filter(item => item.status === this.current)
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f7f7f7;
		view{
			.main{
				.order-list{
					padding: 20rpx;
					.order-item{
						background-color: #fff;
						padding: 20rpx;
						margin-top: 20rpx;
						display: flex;
						flex-direction: column;
						.top{
							display: flex;
							flex-direction: row;
							justify-content: space-between;
							align-items: center;
							padding: 20rpx 0;
							text{
								font-size: 32rpx;
								color: #2979ff;
								font-weight: bold;
							}
							.status{
								width: 120rpx;
								height: 60rpx;
								font-size: 26rpx;
								color: white;
								background-color: #fa3534;
								display: flex;
								justify-content: center;
								align-items: center;
								border-radius: 10rpx;
							}
						}
						.id{
							padding: 20rpx 0;
							font-size: 26rpx;
							color: #666;
							border-top: 4rpx solid #e4e7ed;
						}
						.date{
							font-size: 26rpx;
							color: #666;
						}
					}
				}
			}
		}
	}
</style>
